package cn.pli.bike.ui;

import android.os.Bundle;
import android.view.View;
import android.view.ViewGroup;

import com.framemodule.base.BaseActivityPresenter;
import com.framemodule.base.netstatus.NetUtils;

import java.util.List;

import cn.bingoogolapple.androidcommon.adapter.BGAOnRVItemClickListener;
import cn.pli.bike.R;
import cn.pli.bike.bean.CreditRecord;
import cn.pli.bike.bean.ExpensesRecordBean;
import cn.pli.bike.bean.HttpResult;
import cn.pli.bike.model.UserModel;
import cn.pli.bike.model.subscribers.ProgramSubscriber;

public class JourneyDetailActivity extends BaseActivityPresenter<JourneyDetailDelegate> implements View.OnClickListener {


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setdata();

    }

    @Override
    protected void onResume() {
        super.onResume();
    }

    @Override
    protected void initModel() {

    }

    @Override
    protected void onNetworkConnected(NetUtils.NetType type) {

    }

    @Override
    protected void onNetworkDisConnected() {

    }

    @Override
    protected void bindEvenListener() {
        super.bindEvenListener();
        viewDelegate.setOnClickListener(this, R.id.iv_title_back);
        viewDelegate.getUserInfoAdapter().setOnRVItemClickListener(new BGAOnRVItemClickListener() {
            @Override
            public void onRVItemClick(ViewGroup parent, View itemView, int position) {
                Bundle bundle = new Bundle();
                bundle.putSerializable("expensesRecordBean", viewDelegate.getUserInfoAdapter().getData().get(position));
                readyGo(MyTripActivity.class, bundle);
            }
        });

    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.iv_title_back:
                finish();
                break;
        }


    }


    /**
     * 设置数据
     */
    private void setdata() {
        UserModel.getExpensesRecord(new ProgramSubscriber<HttpResult<List<ExpensesRecordBean>>>() {
            @Override
            public void onNext(HttpResult<List<ExpensesRecordBean>> listHttpResult) {
                viewDelegate.getUserInfoAdapter().setData(listHttpResult.getData());
            }
        });
    }


}
